<script>
	import Vue from 'vue'
	import updateCustomBarInfo from './tuniao-ui/libs/function/updateCustomBarInfo.js'
	import config from './config'
	import store from '@/store'
	import {
		getToken
	} from '@/utils/auth'

	export default {
		onLaunch: function() {
			// 获取设备的状态栏信息和自定义顶栏信息
			// store.dispatch('updateCustomBarInfo')
			updateCustomBarInfo().then((res) => {
			  store.commit('$tStore', {
			    name: 'vuex_status_bar_height',
			    value: res.statusBarHeight
			  })
			  store.commit('$tStore', {
			    name: 'vuex_custom_bar_height',
			    value: res.customBarHeight
			  })
			})
			this.initApp()
		},
		methods: {
			// 初始化应用
			initApp() {
				// 初始化应用配置
				this.initConfig()
				// 检查用户登录状态
				//#ifdef H5
				this.checkLogin()
				//#endif
			},
			initConfig() {
				this.globalData.config = config
			},
			checkLogin() {
				if (!getToken()) {
					this.$tab.reLaunch('/pages/login')
				}
			}
		}
	}
</script>

<style lang="scss">
	@import '@/static/scss/index.scss';
	@import './tuniao-ui/index.scss';
	@import './tuniao-ui/iconfont.css';
</style>